package com.yunxi.module.system.api.oauth2;

import com.yunxi.framework.common.pojo.CommonResult;
import com.yunxi.framework.common.util.object.BeanUtils;
import com.yunxi.module.system.dto.oauth2.OAuth2AccessTokenCheckRespDTO;
import com.yunxi.module.system.model.oauth2.OAuth2AccessTokenDO;
import com.yunxi.module.system.service.oauth2.OAuth2TokenService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 提供 RESTful API 接口，给 Feign 调用
 * </p>
 *
 * @author lidy
 * @since 2024-05-08
 */
@RestController
@Validated
public class OAuth2TokenApiImpl implements OAuth2TokenApi {

    @Resource
    private OAuth2TokenService oAuth2TokenService;

    @Override
    public CommonResult<OAuth2AccessTokenCheckRespDTO> checkAccessToken(String accessToken) {
        OAuth2AccessTokenDO accessTokenDO = oAuth2TokenService.checkAccessToken(accessToken);

        return CommonResult.success(BeanUtils.toBean(accessTokenDO, OAuth2AccessTokenCheckRespDTO.class));
    }
}
